package com.zb.kc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zb.kc.entity.EduTeacher;
import com.zb.kc.dao.EduTeacherDao;
import com.zb.kc.service.IEduTeacherService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 讲师 服务实现类
 * </p>
 *
 * @author wanggen
 * @since 2020-04-02
 */
@Service
public class EduTeacherServiceImpl extends ServiceImpl<EduTeacherDao, EduTeacher> implements IEduTeacherService {

    /**
     * 获取最热门的4个讲师
     * @return
     */
    @Cacheable(value = "eduteacher", key = "'getHotTeacher'")
    @Override
    public List<EduTeacher> getHotTeacher() {
        QueryWrapper<EduTeacher> wrapperTeacher = new QueryWrapper<>();
        wrapperTeacher.orderByDesc("id").last("limit 4");
        return baseMapper.selectList(wrapperTeacher);
    }
}
